package com.zsc.eb.web;

import com.zsc.eb.model.EbNews;
import com.zsc.eb.model.EbProductCategory;
import com.zsc.eb.service.EbNewsService;
import com.zsc.eb.service.EbProductCategorySercie;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/news")
public class NewsController {

    @Autowired
    private EbNewsService ebNewsService;

    @Autowired
    EbProductCategorySercie ebProductCategorySercie;

    @RequestMapping("/detail")
    public String detail(Model model,Integer enId){
        //调用service查询新闻详情
        EbNews ebNewsDetail=ebNewsService.detail(enId);       //查询分类信息
        Map<String, List<EbProductCategory>> categoryMap=ebProductCategorySercie.selectBigAndSmallCate();
        //绑定数据到model
        model.addAttribute("detail",ebNewsDetail);
        model.addAttribute("categoryMap",categoryMap);
        //返回视图名称
        return "news-view";

    }
}